package cn.tedu.boyou.acticle.service.impl;

import cn.tedu.boyou.acticle.domain.DestinationExtend;
import cn.tedu.boyou.acticle.mapper.DestinationExtendMapper;
import cn.tedu.boyou.acticle.service.IDestExtendService;
import cn.tedu.boyou.common.query.DestinationExtendQuery;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 目的地拓展相关服务的实现类
 */
@Service
public class DestExtendServiceImpl implements IDestExtendService{

    @Autowired
    private DestinationExtendMapper destinationExtendMapper;

    @Override
    public List<DestinationExtend> queryDestsWithExtend(DestinationExtendQuery qo) {
        return destinationExtendMapper.selectForList(qo);
    }

    @Override
    public PageInfo<DestinationExtend> query(DestinationExtendQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        return new PageInfo<DestinationExtend>(destinationExtendMapper.selectForList(qo));
    }

    @Override
    public void update(DestinationExtend destinationExtend) {
        if (destinationExtend.getId() == null){
            throw new RuntimeException("目的地标签服务中更新目的地拓展类对象信息时候id为空");
        }
        destinationExtendMapper.updateByPrimaryKey(destinationExtend);
    }

    @Override
    public List<DestinationExtend> getDestByMonth(Long month, int num) {
        return destinationExtendMapper.getDestsNumedByMonth(month,num);
    }
}
